package com.ramms.eater.parser;

import org.w3c.dom.Element;

import com.ramms.eater.parser.base.AbstractParser;
import com.ramms.eater.parser.entity.Article;
import com.ramms.eater.util.Constants;

public class ArticleParser extends AbstractParser<Article> {

	public ArticleParser(String url) {
		super(url, Constants.TAG_ARTICLE);
	}

	@Override
	public Article getItem(Element e) {
		Article article = new Article();
		if(e.getAttribute(Constants.ATTR_TYPE) != null)
			article.setType(e.getAttribute(Constants.ATTR_TYPE));
		if(e.getAttribute(Constants.ATTR_TITLE) != null)
			article.setTitle(e.getAttribute(Constants.ATTR_TITLE));
		if(e.getAttribute(Constants.ATTR_LINK) != null)
			article.setLink(e.getAttribute(Constants.ATTR_LINK));
		if(e.getAttribute(Constants.ATTR_PUBDATE) != null)
			article.setPubDate(e.getAttribute(Constants.ATTR_PUBDATE));
		if(e.getAttribute(Constants.ATTR_DESCRIPTION) != null)
			article.setDescription(e.getAttribute(Constants.ATTR_DESCRIPTION));
		if(e.getAttribute(Constants.ATTR_IMGURL) != null)
			article.setImgUrl(e.getAttribute(Constants.ATTR_IMGURL));
		if(e.getAttribute(Constants.ATTR_PREMIUM) != null)
			article.setPremium(e.getAttribute(Constants.ATTR_PREMIUM));
		if(e.getAttribute(Constants.ATTR_AUDIOFILE) != null)
			article.setAudioFile(e.getAttribute(Constants.ATTR_AUDIOFILE));
		if(e.getAttribute(Constants.ATTR_COUNT) != null)
			article.setCount(e.getAttribute(Constants.ATTR_COUNT));
		if(e.getAttribute(Constants.ATTR_COUNTIPHONE) != null)
			article.setCountIphone(e.getAttribute(Constants.ATTR_COUNTIPHONE));
		return article;
	}

}
